#include "json_debug.h"
#include <stdio.h>
#include <time.h>

void
print_console(char *msg){
	printf("%s\n", msg);
}

int
print_log(char *msg){
	union debug_error_u error;

	time_t raw_time;
	struct tm *time_info;
	time(&raw_time);
	time_info = localtime(&raw_time);
	strcat(msg, "-");
	strcat(msg, asctime(time_info));
	strcat(msg, '\n');

	FILE *f = fopen(log_file, "a");
	if( f == NULL ){
		puts("Could not open file!");
		error = OPEN_FILE_FAIL;
		return error;
	}

	fputs(msg, f);
	if(fclose(f) != 0){
		error = CLOSE_FILE_FAIL;
		return error;	
	}
	return 0;
}
